//forEach()方法演示：该方法可以用来遍历数组
var arr = ["孙悟空", "猪八戒", "沙和尚"];
arr.forEach(function (value, index, obj) {
    console.log(value + " #### " + index + " #### " + obj);
});
console.log("------------------------------------------")
const arr1 = ["孙悟空", "猪八戒", "沙和尚"];
const arr2 = ["白骨精", "玉兔精", "蜘蛛精"];
const arr3 = ["二郎神", "太上老君", "玉皇大帝"];
const result = arr1.concat(arr2, arr3, "牛魔王", "铁扇公主");
console.log(result);
console.log("------------------------------------------")
const arr4 = ["孙悟空", "猪八戒", "沙和尚"];
arr.reverse();
console.log(arr4);
console.log("------------------------------------------")
const arr5 = [1, 3, 2, 11, 5, 6];
arr.sort(function (a, b) {
    return a - b;
});
console.log(arr5);
console.log("------------------------------------------")
//call函数和apply函数
function fun(a, b) {
    console.log("a = " + a);
    console.log("b = " + b);
    console.log("fun = " + this);
}

var obj = {
    name: "obj",
    sayName: function () {
        console.log(this.name);
    }
};

fun(2, 3);
console.log("===============");
fun.call(obj, 2, 3);

console.log("------------------------------------------")
function fun1(a, b) {
    console.log("a = " + a);
    console.log("b = " + b);
    console.log("fun = " + this);
}

const obj6 = {
    name: "obj",
    sayName: function () {
        console.log(this.name);
    }
};

fun1(2, 3);
console.log("===============");
fun.apply(obj6, [2, 3]);
console.log("------------------------------------------")
const str = "Hello,World!";
let result1 = str.slice(1, 4);
console.log(result1);
result1 = str.slice(1);
console.log(result1);
result1 = str.slice(1, -1);
console.log(result1);
console.log("------------------------------------------")








